package com.kevin.design.creationalPattern.factoryMethod;

public class FactoryMethodOfLogger {
    public static void main(String[] args) {
        Logger logger = new DBLoggerFactory().getLogger();
        logger.printLogger();
        Logger serverLogger = new ServerLoggerFactory().getLogger();
        serverLogger.printLogger();
    }
}

interface Logger{
    void printLogger();
}
class ServerLogger implements Logger{

    @Override
    public void printLogger() {
        System.out.println("服务器日志");
    }
}
class DBLogger implements Logger{

    @Override
    public void printLogger() {
        System.out.println("数据库日志");
    }
}

interface LoggerFactory{
    Logger getLogger();
}

class DBLoggerFactory implements LoggerFactory{

    @Override
    public Logger getLogger() {
        return new DBLogger();
    }
}

class ServerLoggerFactory implements LoggerFactory{

    @Override
    public Logger getLogger() {
        return new ServerLogger();
    }
}
